 <%@ page language="java" import="java.util.*" pageEncoding="utf-8" import="pojo.*,base.*,service.*,java.text.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <link rel="stylesheet" type="text/css" href="jquery/jscal2.css" />
   <link rel="stylesheet" type="text/css" href="jquery/border-radius.css" />
    <link rel="stylesheet" type="text/css" href="jquery/steel/steel.css" />
  <style type="text/css">
#list {
           margin-bottom:10px
}
#bottom {
           margin-top:60px
}
#all a {
           text-decoration:none;
           color:black;
           }

#all a:link,.toptext a:visited{color:black;}
#all a:hover{color:#A020F0;}  
       body{
	margin:0;
	padding:40px;
	background-image:url("images/bj.jpg");
	background-repeat:no-repeat;
	font:80% Arial, Helvetica, sans-serif;
	color:#555;
	line-height:100%;
}
 </style>
 <script type="text/javascript" src="jquery/jquery-1.7.2.min.js"></script>
 <script>
 function deleteReview(url){
  if(deleteconfirm()){
  location.href=url;
  }
 }
 function deleteconfirm(){
	if(confirm("确认要删除数据吗"))
		return true;
	return false;
 }
 function openpage(){
 	var page=$("#pagenum").val();
 	location.href="reviewlist.jsp?pageno="+page;
 }
 </script>
 <script src="jquery/jscal2.js"></script>
    <script src="jquery/cn.js"></script>
    
  
  </head>
  
  <body>
   <div id="all">
   
<div id="list">
<%

	request.setCharacterEncoding("utf-8");
    String spageno = request.getParameter("pageno");
    
    SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
    String da=df.format(new Date());
    String key = request.getParameter("key");
    String where=" ";           
    if(key!=null){where+=" where time = '"+key+"%'";}else where+=" where 1=1 ";
    int pageno;//页码
    int pagesize=8;//每页显示行数
   
    if(spageno==null){ pageno = 1;}//当页码为空时默认为1
    
    else pageno=Integer.valueOf(request.getParameter("pageno"));//否则为传过来的页码
  ReviewService us = new ReviewService();
    int size=us.getALL(where);//获取总数量
	try{pageno = Integer.parseInt(spageno);}
	catch(Exception e){}
	
		
	  	

	Page p1=new Page();
								p1.setTotalRecord(size);
								p1.setCurrentPageNo(pageno);
								p1.setPageSize(pagesize);	
	List<review> list = us.getReview(pageno,pagesize,where);//按参数查询
	MemberService service=new MemberService();
		for(int i=0,length=list.size();i<length;i++){
		list.get(i).setUserName(service.getInfo(list.get(i).getUserid()).getUsername());
		}  
	 
		
		if(list!=null)
	 
			
			out.print("共"+size+"个");
			
%>
 
</div>

<br/>
<center>

	<table width="900" border="1">
      <tr>
        <td width="60"><div align="center">用户名</div></td>
        <td width="70"><div align="center">订单号</div></td>
        <td width="87"><div align="center"> 提交时间</div></td>
        <td width="87"><div align="center"> 评价等级</div></td>
        <td width="87"><div align="center"> 具体内容</div></td>
        <td width="87"><div align="center"> 操作</div></td>
        
        
      </tr>
<%
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	for (review inf : list) {
	out.println("<tr><td><div align='center'><a href='meberInfor.jsp?id="+inf.getUserid()+"&type=1'>"+inf.getUserName()+" </a></div></td>");
	out.println("<td><div align='center'>"+inf.getOrderid()+"</div></td>");
	out.println("<td><div align='center'>"+inf.getTime()+"</div></td>");
	 if (inf.getLevel()==1) {
	 out.println("<td><div align='center'>"+"好评"+"</div></td>");
	 }
	 else if (inf.getLevel()==2) {
	 out.println("<td><div align='center'>"+"中评"+"</div></td>");
	 }
	 else
	 out.println("<td><div align='center'>"+"差评"+"</div></td>");
	out.println("<td><div align='center'>"+inf.getContent()+"</div></td>");
%>
<%
	out.println("<td><div align='center'><input type='button' onclick=deleteReview('action/deleteReview.jsp?id="+inf.getId()+"'); value='删除'/></div></td></tr>");
	}
	out.print("<tr><td align='right' colspan='9'><h5>共"+p1.getTotalPage()+"页，当前第"+pageno+"页， ---<a href='reviewlist.jsp?&pageno="+p1.getPrePage()+"'>上一页</a>");
								 out.print("<a href='reviewlist.jsp?&pageno="+p1.getNextPage()+"'>下一页</a><input type=text name=pagenum id=pagenum style=width:20;border:1px solid grey> <a href='javascript:void(0);' onclick=openpage();>跳转</a></h5></td></tr>");
%>
	
</table>
  </center>
	  </div>
	  <div id="bottom">
	  <center>
	  <form  action="reviewlist.jsp" method="post">
<input type="text" name="key" id="date" />
<input type="submit" value="查询"/>
   <script type="text/javascript">
      Calendar.setup({
        inputField : "date",
        trigger    : "date",
        onSelect   : function() { this.hide() },

        dateFormat : "%Y-%m-%d"
      });
    </script>

</form>
</center>
	</div>  
  </body>
</html>
